﻿#include "OperatorsGeoCubeManager.h"

#include "GUIFrame/MainWindow.h"
#include "GUIFrame/CentralWidget.h" 
#include "OperatorsInterface/GraphEventOperator.h"
#include "GUIDialog/GUIGeometryDialog/CreateCudeDialog.h"

#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include "FITK_Interface/FITKInterfaceGeometry/FITKGeoCommandList.h"
#include "FITK_Interface/FITKInterfaceGeometry/FITKAbsGeoCommand.h"
#include "FITK_Interface/FITKInterfaceGeometry/FITKAbsGeoModelBox.h"

namespace ModelOper
{
    OperatorsGeoCubeManager::OperatorsGeoCubeManager()
    {

    }

    OperatorsGeoCubeManager::~OperatorsGeoCubeManager()
    {

    }

    bool OperatorsGeoCubeManager::execGUI()
    {
        GUI::MainWindow * mainWindow = dynamic_cast<GUI::MainWindow *>(FITKAPP->getGlobalData()->getMainWindow());
        if (!mainWindow)return false;
        if (_emitter == nullptr || !mainWindow->getCentralWidget())return false;
        //获取几何数据
        Interface::FITKGeoCommandList* geometryData = FITKAPP->getGlobalData()->getGeometryData<Interface::FITKGeoCommandList>();
        if (geometryData == nullptr) return false;

        int objID = -1;
        this->argValue("objID", objID);
        QString actionName = _emitter->objectName().toLower();
        if (actionName.contains("create"))
        {
            GUI::CreateCudeDialog dialog(this);
            return dialog.exec() == QDialog::Accepted;
        }

        return false;
    }

    bool OperatorsGeoCubeManager::execProfession()
    {
        int objID = -1;
        this->argValue("objID", objID);
        //获取3D区域
//         GUI::Widget3D* widget = this->getCurrent3DWidget();
//         if (!widget) return false;
//         widget->update3DTree();
        //获取三维可视对象数据-用于渲染数据对象
        EventOper::GraphEventOperator* graphOper = FITKOPERREPO->getOperatorT<EventOper::GraphEventOperator>("GraphPreprocess");
        if (graphOper == nullptr)return false;
        graphOper->updateGraph(objID);
        return true;
    }
}
